<template>
  <div class="index">

    <HeadNav></HeadNav>

    <my-scroll class="scroll-box">
    <div class="box">
      <Search class="header"></Search>
      <Banner></Banner>

      <div class="menu">
        <span class="item">
          <router-link to="singers">
            <img src="./../assets/singer.svg">
            <p>歌 手</p>
          </router-link>
        </span>
        <span class="item">
          <router-link to="all-rank">
            <img src="./../assets/rank.svg">
            <p>排 行</p>
          </router-link>
        </span>
        <span class="item">
          <router-link to="null-page">
            <img src="./../assets/song-menu.svg">
            <p>分 类 歌 单</p>
          </router-link>
        </span>
        <span class="item">
          <router-link to="null-page">
            <img src="./../assets/radio.svg">
            <p>电 台</p>
          </router-link>
        </span>
        <span class="item">
          <router-link to="null-page">
            <img src="./../assets/mv.svg">
            <p>M V</p>
          </router-link>
        </span>
      </div>

      <div class="recommend">
        <div class="top">
          <p class="title">推荐歌单</p>
          <div class="more">更多<span class="moreIcon"></span></div>
        </div>
        <div class="container">
          <span class="item"
            @click="selectSongList(item.id)"
            v-for="(item, index) in recommendList"
            :key="index">
            <div class="iconContent">
              <div class="listenNum">
                <img src="../assets/headset.svg">
                <span>11.2万</span>
              </div>
              <img class="playIcon" src="../assets/play.svg">
            </div>
            <img :src="item.picUrl">
            <p>{{item.name}}</p>
          </span>
        </div>
      </div>

      <div class="footer">我也是有底线的哟~</div>
    </div>
    </my-scroll>
  </div>
</template>

<script>
  import HeadNav from "../components/HeadNav";
  import Search from "../components/Search";
  import Banner from "../components/Banner";
  import MyScroll from "../components/MyScroll";
  export default {
    name: "Index",
    components: {
      HeadNav,
      Search,
      Banner,
      MyScroll
    },
    data(){
      return {
        recommendList: []
      };
    },
    methods: {
      getRecommendList(){
        this.$axios.get('/api/personalized?limit=12')
          .then(res => {
            this.recommendList = res.data.result;
          })
          .catch(err => console.log(err));
      },
      selectSongList(id){
        /**
         * id: id,  id
         * title: name, 标题
         * backgroundUrl: picUrl,  banner图片
         * */
        this.$router.push({
          name: 'song-sheet-details',
          params: {
            id: id
          }
        })
      }
    },
    created() {
      this.getRecommendList();
    }
  }
</script>

<style scoped lang="scss">
  .index{
    width: 100%;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 0;
    background-image: $dark-gradient-backgroud;
    background-attachment: fixed;
  }
  .scroll-box{
    width: 100vw;
    height: 100vh;
    overflow: auto;
      /** 这里overflow一定得加上auto或scroll或hidden，不加的话会将迷你播放器组件给挤下去屏幕一点 */
      .box{
        padding-top: 60px;
        padding-bottom: 120px;
      }
  }
  .header{
    width: 100%;
  }
  .menu{
    width: 92%;
    height: auto;
    margin-top: 0.38rem;
    margin-left: 4%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    .item{
      width: 20vw;
      height: 20vw;
      /* margin: auto 4%; */
      flex-shrink: 0;
      overflow: hidden;
      a{
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-decoration: none;
      }
      a:hover{
        text-decoration: none;
      }
      img{
        width: 10vw;
        height: 10vw;
      }
      p{
        width: 100%;
        margin-top: 2vw;
        line-height: 0.36rem;
        font-size: 0.3rem;
        color: $dark-color3;
        text-align: center;
        overflow: hidden;
      }
    }
  }
  .recommend{
    width: 92%;
    height: auto;
    margin-top: 20px;
    margin-left: 4%;
    color: $dark-color3;
    position: relative;
    .top{
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
      padding-bottom: 10px;
      .title{
        font-size: 0.4rem;
      }
      .more{
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 0.3rem;
        color: $dark-color1;
        .moreIcon{
          margin-left: 4px;
          width: 6vw;
          height: 6vw;
          background-image: url("./../assets/more.svg");
          background-size: cover;
          background-repeat: no-repeat;
        }
      }

    }
    .container{
      width: 100%;
      height: auto;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      .item{
        width: 30vw;
        height: 45vw;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex-direction: column;
        position: relative;
        .iconContent{
          width: 30vw;
          height: 30vw;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: flex-end;
          position: absolute;
          top: 0;
          right: 0;
          .listenNum{
            margin-top: 2px;
            margin-right: 2px;
            padding: 2px;
            display: flex;
            align-items: center;
            background: rgba($color: #000000, $alpha: 0.1);
            img{
              width: 5vw;
              height: 5vw;
              margin: 0;
              border-radius: 0;
            }
            span{
              font-size: 0.2rem;
            }
          }
          .playIcon{
            width: 5vw;
            height: 5vw;
            margin-right: 5px;
            margin-bottom: 10px;
            border-radius: 0;
          }
        }
        img{
          width: 30vw;
          height: 30vw;
          margin-bottom: 6px;
          border-radius: 6px;
        }
        p{
          display: -webkit-box;
          width: 28vw;
          margin-left: 1vw;
          font-size: 0.3rem;
          word-spacing: 0.1rem;
          line-height: 0.38rem;
          white-space: pre-line;
          text-overflow: ellipsis;
          word-wrap: break-word;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
        }
    }
  }
}
  .footer{
    color: $dark-color3;
    font-size: 0.3rem;
    word-spacing: 0.2rem;
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
</style>